import Vue from 'vue';
import Router from 'vue-router';

const originalReplace = Router.prototype.replace;
Router.prototype.replace = function replace(location) {
    return originalReplace.call(this, location).catch(err => err);
};
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
};

Vue.use(Router);

export default new Router({
    routes: [{
            path: '/',
            redirect: '/index'
        },
        {
            path: '/index',
            component: () =>
                import ('../components/page/index.vue'),
            meta: { title: '在线购买车险' }
        },

        {
            path: '/bx',
            component: () =>
                import ('../components/page/bx.vue'),
            meta: { title: '保险 | 在线购买车险' }
        },

        {
            path: '/my',
            component: () =>
                import ('../components/page/my.vue'),
            meta: { title: '我的保单 | 在线购买车险' }
        },

        {
            path: '/me',
            component: () =>
                import ('../components/page/me.vue'),
            meta: { title: '个人中心 | 在线购买车险' }
        },

        {
            path: '/login',
            component: () =>
                import ('../components/page/login.vue'),
            meta: { title: '登录 | 在线购买车险' }
        },
        {
            path: '/sign-in',
            component: () =>
                import ('../components/page/sign-in.vue'),
            meta: { title: '注册 | 在线购买车险' }
        },

        {
            path: '*',
            redirect: '/'
        }
    ]
});